package com.xm.xmapp.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.xm.xmapp.FeedbackActivity;
import com.xm.xmapp.QuestionListActivity;
import com.xm.xmapp.R;
import com.xm.xmapp.ShowURLActivity;
import com.xm.xmapp.app.Constants;
import com.xm.xmapp.app.MyAppcation;

public class PersonProblemDialog extends Dialog {

	Activity activity;
	public interface OnClickPhoto {
		void takePhotoFramCamera();

		void takePhotoFromSrc();
	}

	public PersonProblemDialog(Context context, int theme) {
		super(context, theme);
	}

	public PersonProblemDialog(Activity activity) {
		this(activity, R.style.share_Dialog);
		this.activity = activity;
	}


	@SuppressWarnings("deprecation")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_personproblem);
		View.OnClickListener l = new View.OnClickListener() {

			@Override
			public void onClick(View v) {

				Intent intent;
				switch (v.getId()) {
				case R.id.cancle:
					dismiss();
					break;
				case R.id.feedback:
					intent = new Intent(MyAppcation.getMyAppcation(), FeedbackActivity.class);
					activity.startActivity(intent);

					break;
				case R.id.problem:
					intent = new Intent(MyAppcation.getMyAppcation(), QuestionListActivity.class);
					activity.startActivity(intent);

					break;
				case R.id.tv_car_guide:
					intent = new Intent(MyAppcation.getMyAppcation(), ShowURLActivity.class);
					intent.putExtra("url", Constants.CAR_GUIDE_URL);
					intent.putExtra("go_back_wab", true);
					intent.putExtra("title", "车辆指引");
					activity.startActivity(intent);
					break;
				default:
					break;
				}

			}
		};

		findViewById(R.id.cancle).setOnClickListener(l);
		findViewById(R.id.feedback).setOnClickListener(l);
		findViewById(R.id.problem).setOnClickListener(l);
		findViewById(R.id.tv_car_guide).setOnClickListener(l);

		Window window = getWindow();
		WindowManager.LayoutParams wl = window.getAttributes();
		wl.alpha = 1.0f;
		wl.gravity = Gravity.BOTTOM;

		WindowManager wm = activity.getWindowManager();
		wl.width = wm.getDefaultDisplay().getWidth();
		window.setAttributes(wl);
		setCancelable(true);
		setCanceledOnTouchOutside(true);

	}

}
